import { ActionButton, Switch } from "@adobe/react-spectrum"
import { useState } from "react";
import { useFetcher } from "react-router";


export function SwitchCommand({ device }: { device: Pick<Device, "guid"> }) {

    let fetcher = useFetcher();

    const [command, setCommand] = useState("");


    return (
        <>
            <fetcher.Form method="post" action="/commands/create">

                <ActionButton type="submit" onPress={() => setCommand("toggle")}>
                    {/* {isLoggingOut ? "退出中..." : "退出"} */}
                    开/关
                </ActionButton>

                < input type="hidden" name="command" value={command} />
                < input type="hidden" name="device" value={device.guid} />
                < input type="hidden" name="commandType" value="2" />

            </fetcher.Form>


        </>

    )

}
